package stu.day9_day18;

public class LeetCode167 {
    public int[] twoSum(int[] numbers, int target) {
        int first = 0;
        int end = numbers.length - 1;
        while (first < end) {
            if (numbers[first] + numbers[end] == target) {
                return new int[]{first, end};
            }else if (numbers[first] + numbers[end] < target) {
                first += 1;
            }else if (numbers[first] + numbers[end] > target) {
                end -= 1;
            }
        }
        return new int[0];
    }
}
